// import banner  from '@assets/ad/banner-0722-alert.png'
// import banner  from '@assets/ad/banner_alert_0810.png'
import banner  from '@assets/ad/banner_alert_0819.png'
import ic_del  from "@assets/ad/ic_del.png"
// import xueqin  from "@assets/xueqin.png"
import Rest from "@module/Rest";



export default class PopUp extends React.Component{
    constructor(props) {
        super(props);
        this.state = {
            imgurl:"",
            advertUrl:""
        };
    }
    componentDidMount() {
        // HttpUtils.getBNNER()
        //     .then(res => {
        //         console.log(res);
        //         this.setState({
        //             banners: res.ads.MAIN_BNNER
        //         });
        //     })
        //     .catch(err => {
        //         console.log(err);
        //     });
        // let url = `/shop/noLogin/poster/queryAdvertListByAdvertGroup`;
        let url = `/store/api/homepage/advert/queryAdvertListByAdvertGroup
        `;
        Rest.post(url, {groupCode:'G-1-1-1-2'})
            .then(res => {
                console.log(res);
                
                if(res.code=='200') {
                    if(res.data) {
                        let {imgurl,advertUrl}=res.data[0];
                        this.setState({
                            imgurl,advertUrl
                        });
                    }
                    
                }
            })
    }
    render(){
        const {hide,}=this.props
        return(
            <React.Fragment>
                {this.state.imgurl&&
                    <div className="home-popup">
                        <div className="home-popup-modal"></div>
                        <div className="home-popup-box">
                            <img src={this.state.imgurl}
                                onClick={()=>{
                                    window.open(this.state.advertUrl);
                                }}
    
                            />
                        </div>
                        <img
                            src={ic_del}
                            className="home-popup-del"
                            onClick={()=>{
                                hide()
                            }}
                        />
                    </div>
                }
            </React.Fragment>
        )
    }
}